#include <stdio.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <sys/ipc.h>

int main()
{
	key_t key = ftok(".",105);
	if(key == -1)
		perror("ftok") , exit(-1);
	int shmid = shmget(key,4,IPC_CREAT | IPC_EXCL | 0660);
	if(shmid == -1)
		perror("shmget") , exit(-1);
	printf("shmid = %d\n",shmid);
	void *p = shmat(shmid,0,0);
	if(p == (void *) -1)
	        perror("shmat") , exit(-1);
/*	int *p1 = p ;
	*p1 = 100;
	shmdt(p);*/
}
